<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('转移申请信息')"/>
    <th:block th:include="include :: ztree-css"/>
    <th:block th:include="include :: bootstrap-fileinput-css"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-result-edit">
        <input type="hidden" th:field="${info.tid}" name="tid">
        <div class="col-md-12">
            <div class="form-group">
                <label class="col-sm-3 control-label">任务标题：</label>
                <div class="col-sm-9">
                    <input type="text" name="target" class="form-control" th:value="${info.target}"/>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">执行人员：</label>
            <div class="col-sm-9">
                <select class="form-control" name="dlogname" id="dlogname">
                    <option value="">--请选择--</option>
                    <option th:each="users:${users}" th:value="${users.loginName}" th:text="${users.userName}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">完成时间：</label>
            <div class="col-sm-8">
                <input type="date" name="begin_date" th:value="${#dates.format(info.begin_date,'yyyy-MM-dd')}" />-
                <input type="date" name="end_date" th:value="${#dates.format(info.end_date,'yyyy-MM-dd')}" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">紧急程度：</label>
            <div class="col-sm-8">
                <div class="radio-box">
                    <span>普通：</span><input type="radio" value="0" name="emerg" />
                </div>
                <div class="radio-box">
                    <span>紧急：</span><input type="radio" value="1" name="emerg" />
                </div>
                <div class="radio-box">
                    <span>非常紧急：</span><input type="radio" value="2" name="emerg" />
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">任务内容：</label>
            <div class="col-sm-9">
                <textarea type="text" name="detail" class="form-control" th:text="${info.detail}"></textarea>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">文件上传：</label>
            <div class="col-sm-8">
                <input class="form-control" type="file" name="fjupload" id="fjupload"><button id="sc" value="" onclick="upload()">修改上传文件</button>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label ">文件地址：</label>
                <div class="col-sm-8">
                    <input class="form-control" type="text" name="fjurl" id="fjurl" th:value="${info.fjurl}" />
                </div>
            </div>
        </div>
    </form>
    <div class="row">
        <div class="col-sm-offset-5 col-sm-10">
            <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存</button>&nbsp;
            <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭 </button>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: ztree-js"/>
<script type="text/javascript">
    function submitHandler() {
        if ($.validate.form()) {
            add();
        }
    }

    function add() {
        var vals = $("#form-result-edit").serialize();
        $.ajax({
            cache: true,
            type: "POST",
            url: ctx + "cms/mm/task/doEditTask",
            data: vals,
            async: false,
            error: function (request) {
                $.modal.alertError("系统错误");
            },
            success: function (data) {
                $.operate.successCallback(data);
            }
        });
    }

    function upload() {
        var file = $("#fjupload")[0].files[0];
        var formdata = new FormData();
        formdata.append("file", file);
        $.ajax({
            url: ctx + "cms/mm/task/uploadFile",
            data: formdata,
            async: true,
            type: "post",
            processData: false,
            contentType: false,
            /*success: function(result) {
                $.operate.successCallback(result);
            }*/
            success: function (result) {
                $.modal.alertSuccess("成功!");
                console.log(result);
                //给地址赋值
                $("#fjurl").val(result);

            },
            error: function (result) {
                $.modal.alertError("失败！");
            }
        })
    }

</script>
</body>
</html>
